<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // ## 4. aabccd，去掉重复的字符，使结果显示 abcd
        var str = 'aabccd'
        var arr = str.split('')
        var arr1 = arr.reduce(function(pre,cur){
            return pre.indexOf(cur) === -1? pre.concat(cur): pre
        },[]).reduce(function(pre,cur){
            return pre += cur 
        },'')
        console.log(arr1)
    </script>
</body>
</html>